<?php
class ControllerExtensionModuleMobileHotSearch extends Controller {
	public function index($setting) {
		if (!$this->config->get('is_mobile')) return;
		if (!$this->config->get('mobile_hot_search_status')) return;

		$data['hot_search_keywords'] = array();
		$data['mobile_hot_search_title'] = $this->config->get('mobile_hot_search_title');
		$hot_search_keywords = $this->config->get('mobile_hot_search');
		if (!is_array($hot_search_keywords) || empty($hot_search_keywords)) return;

		$sort_order = array();
		foreach ($hot_search_keywords as $key => $value) {
			$sort_order[$key] = $value['sort_order'];
		}
		array_multisort($sort_order, SORT_ASC, $hot_search_keywords);

		foreach($hot_search_keywords as $keyword) {
			if($keyword['status']) {
				$data['hot_search_keywords'][] = $keyword;
			}
		}

		return $this->load->view('extension/module/mobile_hot_search', $data);
	}
}
